def reLoadSession(CheckCall="checkSession"):
    def decorator(func):
        def inner(*args, **kwargs):
            t = args[0]  # type: object
            s = t.__getattribute__("storage_session")
            if s != None and len(s) > 0:
                if type(CheckCall)==str:
                    if t.__getattribute__(CheckCall)():
                        return t
                elif type(CheckCall).__name__=="function":
                    if CheckCall(t):
                        return t
            return func(*args, **kwargs)

        return inner

    return decorator


class Test2:
    storage_session = "1234567"

    def checkSession(self):
        if self.storage_session == "123456":
            print("使用session登录成功")
            return True
        else:
            print("使用session登录失败")
            return False

    @reLoadSession(checkSession)
    def login(self):
        print("正在使用验证码登录")


Test2().login()
